package cn.edu.scujcc.helloworld;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.annotation.JsonFormat;

@RestController
@RequestMapping("/user")
public class HelloController {
	
	@GetMapping("/hello")
	public Map<String,Object> sayHello() {
		Map<String,Object> result = new HashMap<>();
		result.put("msg", "Hello");
		result.put("dt", Calendar.getInstance().getTimeInMillis());
		return result;
	}
	@PostMapping("/save")
	public String save() {
		return "save";
	}
	@DeleteMapping("/dele")
	public String dele() {
		return "OK";
	}
	
	public Map<String,Object> sayHello(@PathVariable String name){
		Map<String,Object> result = new HashMap<>();
		result.put("message", "Hello,"+name);
		return result;
	}
	
	@Autowired
	private ChannelService service;
	@GetMapping("/test")
	public Channel test() {
		Channel c = service.getChannel("1");
		return c;
	}
	
	
}
